home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / RCS / testNeXT2Mac.m,v < prev    next >
Text File  |  1995-06-12  |  3KB  |  129 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.1;
  5. locks    death:1.2;
  6. comment  @@;
  7.  
  8.  
  9. 1.2
  10. date     93.04.04.23.45.39;  author death;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     93.01.10.15.09.03;  author death;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Sun Apr  4 23:45:39 PDT 1993
  27. @
  28. text
  29. @#import "NeXTToMacText.h"
  30. #import "common.h"
  31. #import <stdio.h>
  32.  
  33. void main()
  34. {
  35.     Instance    converter;
  36.     Integer    index;
  37.     Character    theChar, strictChar;
  38.     CString        source = "Hi there how are you doing?";
  39.     ErrorCode        errorone, errortwo;
  40.     FILE*    theFile;
  41.     CString    result, buffer;
  42.     Integer    resultsize;
  43.     Integer    ctr, colctr = 1;
  44.  
  45.     converter = [[NeXTToMacText alloc] init];
  46.     //
  47.     //    Convert an ascii char, an existing 8 bit char, and a characcter we know won't convert
  48.     //
  49.     theChar = [converter ConvertCharacter: 'A'];
  50.     errorone = [converter GetErrorCode];
  51.     printf("Character A: %c (bool result: %d)\n", theChar, errorone);
  52.  
  53.     theChar = [converter ConvertCharacter: 0xB6];
  54.     errorone = [converter GetErrorCode];
  55.     printf("Character paragraph: %c (bool result: %d)\n", theChar, errorone);
  56.  
  57.     theChar = [converter ConvertCharacter: 0xE6];
  58.     errorone = [converter GetErrorCode];
  59.     printf("Can't convert eth : %c  (bool result: %d)\n", theChar, errorone);
  60.  
  61.     for (index = 0; index < 256; index++)
  62.     {
  63.         theChar = [converter ConvertCharacter: index];
  64.         errorone = [converter GetErrorCode];
  65.         [converter ConvertSingleQuotes: YES];
  66.         strictChar = [converter ConvertCharacter: index];
  67.         errortwo = [converter GetErrorCode];
  68.         [converter ConvertSingleQuotes: NO];
  69.         printf("Converting NeXT 0x%X to Mac 0x%X (%c)  (error: %d) [quote mode: 0x%X (%c) (error: %d)]\n",
  70.             index,
  71.             theChar, theChar, errorone,
  72.             strictChar, strictChar, errortwo);
  73.     }
  74.  
  75.     // part two.
  76.     buffer = NewCString(512);
  77.     
  78.     for (ctr = 0; ctr < 256; ctr++)
  79.     {
  80.         if (colctr != 16)
  81.         {
  82.             buffer[ctr*2] = ctr;
  83.             buffer[(ctr*2)+1] = ' ';
  84.             colctr++;
  85.         }
  86.         else
  87.         {
  88.             buffer[ctr*2] = ctr;
  89.             buffer[(ctr*2)+1] = '\r';
  90.             colctr = 1;
  91.         }
  92.     }
  93.     buffer[512] = EndOfCString;
  94.     printf("Source text is: \n%s\n", &buffer[1]); // skip initial null
  95.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 512];
  96.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  97.     printf("Size of result: %d\n", resultsize);
  98.     printf("Results text is: \n");
  99.     for (ctr = 0; ctr < resultsize; ctr ++)
  100.         printf("%c", result[ctr]);
  101.     printf("\n");
  102.     //    test that it expands its internal buffer alright by giving it some text which we
  103.     //    know will multiply in size when it comes out. .. convert lots of Thorns
  104.     for (ctr = 0; ctr < 16; ctr++)
  105.         buffer[ctr] = 0xFC;
  106.     buffer[16] = EndOfCString;
  107.     printf("Source text is: \n%s\n", (CString)buffer);
  108.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 16];
  109.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  110.     printf("Size of result: %d\n", resultsize);
  111.     printf("Results text is: \n");
  112.     for (ctr = 0; ctr < resultsize; ctr ++)
  113.         printf("%c", result[ctr]);
  114.     printf("\n");
  115.     
  116.     FreeCString(result);
  117.     FreeCString(buffer);
  118.     close(theFile);
  119.     [converter    free];
  120. }@
  121.  
  122.  
  123. 1.1
  124. log
  125. @Sun Jan 10 15:09:03 PST 1993
  126. @
  127. text
  128. @@
  129.